﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Antioch
{
	class DrawFrame
	{
		public static void Draw(SpriteBatch with, Texture2D Sprite, int BorderSize, Rectangle Dest)
		{
			if (Dest.Width < BorderSize || Dest.Height < BorderSize) return;

			//Draw corners
			with.Draw(Sprite, new Rectangle(Dest.X, Dest.Y, BorderSize, BorderSize), //NW 
				new Rectangle(0, 0, BorderSize, BorderSize), Color.White);
			with.Draw(Sprite, new Rectangle(Dest.X + Dest.Width - BorderSize, Dest.Y, BorderSize, BorderSize), //NE
				new Rectangle(Sprite.Width - BorderSize, 0, BorderSize, BorderSize), Color.White);
			with.Draw(Sprite, new Rectangle(Dest.X + Dest.Width - BorderSize, Dest.Y + Dest.Height - BorderSize, BorderSize, BorderSize), //SE
				new Rectangle(Sprite.Width - BorderSize, Sprite.Height - BorderSize, BorderSize, BorderSize), Color.White);
			with.Draw(Sprite, new Rectangle(Dest.X, Dest.Y + Dest.Height - BorderSize, BorderSize, BorderSize), //SW
				new Rectangle(0, Sprite.Height - BorderSize, BorderSize, BorderSize), Color.White);
 
 
			//Draw sides
			with.Draw(Sprite, new Rectangle(Dest.X, Dest.Y + BorderSize, BorderSize, Dest.Height - 2 * BorderSize), //W
				new Rectangle(0, BorderSize, BorderSize, Sprite.Height - 2 * BorderSize), Color.White);
			with.Draw(Sprite, new Rectangle(Dest.X + BorderSize, Dest.Y, Dest.Width - 2 * BorderSize, BorderSize), //N
				new Rectangle(BorderSize, 0, Sprite.Width - 2 * BorderSize, BorderSize), Color.White);
			with.Draw(Sprite, new Rectangle(Dest.X + Dest.Width - BorderSize, Dest.Y + BorderSize, BorderSize, Dest.Height - 2 * BorderSize), //E
				new Rectangle(Sprite.Width - BorderSize, BorderSize, BorderSize, Sprite.Height - 2 * BorderSize), Color.White);
			with.Draw(Sprite, new Rectangle(Dest.X + BorderSize, Dest.Y + Dest.Height - BorderSize, Dest.Width - 2 * BorderSize, BorderSize), //S
				new Rectangle(BorderSize, Sprite.Height - BorderSize, Sprite.Width - 2 * BorderSize, BorderSize), Color.White);

			//Draw center
			with.Draw(Sprite, new Rectangle(Dest.X + BorderSize, Dest.Y + BorderSize, Dest.Width - 2 * BorderSize, Dest.Height - 2 * BorderSize),
				new Rectangle(BorderSize, BorderSize, Sprite.Width - 2 * BorderSize, Sprite.Height - 2 * BorderSize), Color.White);

		}
	}
}
